﻿using System;
using System.Web;
using System.Data;
using System.Data.SqlClient;

namespace Team4Mock.DAO
{
    
    public class SupportDAO
    {
        Helper h=new Helper();
        public  DataTable GetData(int idSupport)
        {
            SqlParameter[] p = new SqlParameter[1];
            p[0] = new SqlParameter("@id", idSupport);
            p[0].SqlDbType = SqlDbType.Int;

            return h.GetData("Support_Getdata",p);
        }
        public DataTable GetDataByiD(int id)
        {
            SqlParameter []p=new SqlParameter[1];
            p[0]=new SqlParameter("@id",id);
            p[0].SqlDbType = SqlDbType.Int;
            return h.GetData("Support_GetdataByID",p);
        }
        public void Del(int id)
        {
            SqlParameter[] p = new SqlParameter[1];
            p[0] = new SqlParameter("@id", id);
            p[0].SqlDbType = SqlDbType.Int;
            h.ExecuteNonQuerry("Support_Del",p);
        }
        public void Insert(string url,string des,string type,string user,string date,int orgid,int active)
        {
            SqlParameter[] p = new SqlParameter[7];
            p[0] = new SqlParameter("@url", url);
            p[0].SqlDbType = SqlDbType.VarChar;
            p[1] = new SqlParameter("@des", des);
            p[1].SqlDbType = SqlDbType.NVarChar;
            p[2] = new SqlParameter("@type", type);
            p[2].SqlDbType = SqlDbType.VarChar;
            p[3] = new SqlParameter("@user", user);
            p[3].SqlDbType = SqlDbType.VarChar;
            p[4] = new SqlParameter("@date", date);
            p[4].SqlDbType = SqlDbType.SmallDateTime;
            p[5] = new SqlParameter("@orgid", orgid);
            p[5].SqlDbType = SqlDbType.Int;
            p[6] = new SqlParameter("@active", active);
            p[6].SqlDbType = SqlDbType.Int;
            h.ExecuteNonQuerry("Support_Insert", p);
        }
        public void Update(string url, string des, string type, int active,int id)
        {
            SqlParameter[] p = new SqlParameter[5];
            p[0] = new SqlParameter("@url", url);
            p[0].SqlDbType = SqlDbType.VarChar;
            p[1] = new SqlParameter("@des", des);
            p[1].SqlDbType = SqlDbType.NVarChar;
            p[2] = new SqlParameter("@type", type);
            p[2].SqlDbType = SqlDbType.VarChar;
            p[3] = new SqlParameter("@active", active);
            p[3].SqlDbType = SqlDbType.Int;
            p[4]=new SqlParameter("@id",id);
            p[4].SqlDbType = SqlDbType.Int;
            h.ExecuteNonQuerry("Support_Update", p);
        }
    }
}